Every boxplot means a monitoring point (Ponto de monitoramento (or PM) in portuguese). My goal here is to analyze the evolution between decades of each water quality parameter that compounds the Water Quality Index (WQI).
The river flows in the east-west direction as shown in the image below.
The logic behind the sorting in the boxplots is because of 2 main reasons:
Some features that I want to add: - If the parameter is x, then use x’s classes (with its own classes background color plotted) - Define the timescale, should act just like a filter
# plan_wide_19902020 %>%
# filter(ANO_COLETA > "1990" &
# ANO_COLETA <= "2000")87398500, 87398980, 87398900, 87398950, 87405500, 87406900, 87409900
~facet.gridNamon tá com com casa decimal "," e
ptot tá com "."| 1990-2000 | 2000-2010 | 2010-2020 |
|---|---|---|
| 1990-2000 | 2000-2010 | 2010-2020 |
# install.packages(tidyverse)# library(readr)
# library(rmarkdown)
# # library(qboxplot)
# library(readxl)
# library(pillar)
# library(dplyr)
# library(tidyverse)
# library(gapminder)
# library(knitr)
# library(kableExtra)
# library(ggpubr)
# library(gridExtra)
# library(modelsummary)
# library(gtsummary)
# library(GGally)
pacman::p_load(readr, rmarkdown, readxl,
pillar, dplyr, tidyverse,
gapminder, knitr, kableExtra,
gridExtra, #modelsummary,
gtsummary, ggplot2,
ggbeeswarm, GGally)
# pacman::p_load(tibbletime)knitr::knit_hooks$set(time_it = local({
now <- NULL
function(before, options) {
if (before) {
# record the current time before each chunk
now <<- Sys.time()
} else {
# calculate the time difference after a chunk
res <- difftime(Sys.time(), now)
# return a character string to show the time
paste("Time for this code chunk to run:", res)
}
}
}))
knitr::opts_chunk$set(time_it = TRUE)## Rows: 1,179
## Columns: 53
## $ CODIGO <chr> "87398950", "87398900", "87405500", "87398950", "8~
## $ MUNICIPIO <chr> "GRAVATAI - RS", "GRAVATAI - RS", "CACHOEIRINHA - ~
## $ ENDERECO <chr> "A PE NO TREVO, NA PONTE VELHA OU DE BARCO VINDO D~
## $ COORD_GEO_LAT_GRAU <dbl> -51.00064, -50.93414, -51.11733, -51.00064, -50.93~
## $ COORD_GEO_LONG_GRAU <dbl> -29.95055, -29.95075, -29.95055, -29.95055, -29.95~
## $ Altitude <dbl> 7, 6, 6, 7, 6, 7, 9, 9, 6, 6, 6, 6, 7, 6, 7, 6, 13~
## $ RECURSO_HIDRICO <chr> "RIO GRAVATAI", "RIO GRAVATAI", "RIO GRAVATAI", "R~
## $ DATA_COLETA <date> 1994-12-08, 1994-02-03, 1994-02-03, 1993-10-06, 1~
## $ ANO_COLETA <dbl> 1994, 1994, 1994, 1993, 1994, 1995, 1994, 1995, 19~
## $ Alcalinidade <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ Condutividade <dbl> 90.0, 47.0, 147.0, 43.0, NA, 47.0, 70.0, 60.6, 72.~
## $ DBO <dbl> 5, 5, 11, 3, 3, 2, 4, 3, 4, 2, 5, 3, 1, 1, 5, 2, 2~
## $ IQA_DBO <dbl> 53.97, 53.97, 29.03, 69.06, 69.06, 78.12, 61.05, 6~
## $ DQO <dbl> 26, 47, 34, 37, 54, 23, 35, 25, 28, 40, 21, 35, 21~
## $ E_coli <dbl> 4.0, 40.0, 12.8, 10.4, 32.0, 16.8, 40.0, 6.4, 10.4~
## $ fosfato_orto <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ fosforo_total <dbl> 0.1130, 0.0883, 0.3530, 0.0908, 0.1180, 0.0326, 0.~
## $ IQA_Ptot <dbl> 72.73, 77.95, 38.26, 77.41, 71.71, 91.16, 63.37, 6~
## $ Nitrato <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ Nitrito <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ nitro_organico <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ nitro_amon <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ nitro_kjeldahl <dbl> 1.42, 1.61, 6.62, 0.79, 1.45, 0.76, 1.23, 1.37, 2.~
## $ nitro_total <dbl> 1.42, 1.61, 6.62, 0.79, 1.45, 0.76, 1.23, 1.37, 2.~
## $ IQA_NitroTot <dbl> 89.02, 87.64, 59.33, 93.74, 88.80, 93.97, 90.41, 8~
## $ oxigenio_dissolvido <dbl> 6.5, 8.7, 5.3, 7.8, 7.6, 8.5, 7.3, 6.9, 6.7, 6.3, ~
## $ sat_OD <dbl> 78.162, 116.280, 70.837, 85.270, 96.442, 85.565, 7~
## $ IQA_OD <dbl> 84.58, 90.92, 76.25, 89.67, 97.53, 89.88, 79.57, 7~
## $ pH <dbl> 6.9, 6.8, 6.6, 6.4, 6.9, 6.7, 6.6, 6.7, 6.3, 7.1, ~
## $ IQA_pH <dbl> 89.76, 87.72, 82.86, 76.96, 89.76, 85.42, 82.86, 8~
## $ SDT <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ SST <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ temp_agua <dbl> 25.0, 31.0, 31.0, 20.0, 28.0, 16.0, 16.0, 16.0, 18~
## $ temp_ar <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ transparencia_agua <dbl> NA, 40.0, 30.0, NA, NA, NA, 50.0, 20.0, 40.0, 20.0~
## $ turbidez <dbl> 20.0, 20.0, 8.5, 23.0, 19.0, 17.0, 12.0, 22.0, 17.~
## $ IQA_Turb <dbl> 61.87, 61.87, 80.20, 58.73, 63.07, 65.69, 73.57, 5~
## $ vazao_rio <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ Vazao <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ coliformes_termo <dbl> 5, 50, 16, 13, 40, 21, 50, 8, 13, 23, 700, 16, 8, ~
## $ IQA_coli <dbl> 76.58, 47.21, 60.44, 63.04, 49.66, 57.12, 47.21, 6~
## $ solidos_totais <dbl> 121, 112, 160, 93, 127, 75, 80, 201, 84, 123, 78, ~
## $ IQA_Sól_Tot <dbl> 83.91, 84.69, 79.40, 85.78, 83.28, 86.08, 86.07, 7~
## $ `IQA_^OD` <dbl> 2.126, 2.153, 2.089, 2.148, 2.178, 2.148, 2.104, 2~
## $ `IQA_^temp_agua` <dbl> 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.58, 1.~
## $ `IQA_^coli` <dbl> 1.917, 1.783, 1.850, 1.862, 1.796, 1.835, 1.783, 1~
## $ `IQA_^pH` <dbl> 1.715, 1.711, 1.699, 1.684, 1.715, 1.705, 1.699, 1~
## $ `IQA_^DBO` <dbl> 1.175, 1.175, 1.271, 1.116, 1.116, 1.072, 1.149, 1~
## $ `IQA_^NitroTot` <dbl> 1.567, 1.564, 1.504, 1.575, 1.566, 1.575, 1.569, 1~
## $ `IQA_^Ptot` <dbl> 1.535, 1.546, 1.440, 1.545, 1.533, 1.570, 1.514, 1~
## $ `IQA_^Turb` <dbl> 1.391, 1.391, 1.420, 1.385, 1.393, 1.398, 1.410, 1~
## $ `IQA_^Sól_Tot` <dbl> 1.425, 1.426, 1.419, 1.428, 1.424, 1.428, 1.428, 1~
## $ IQA <dbl> 61.876, 58.452, 57.556, 57.129, 56.405, 56.189, 55~
Time for this code chunk to run: 0.452330112457275
Time for this code chunk to run: 0.18160605430603
# Como há dados faltantes, no cálculo entre o produto das colunas, ele acaba interpretando como se fosse zero, mas na verdade é NA
plan_wide_19902020 <- plan_wide_19902020 %>%
mutate(IQA = ifelse(IQA == 0, NA, IQA))
parametros_IQA <- plan_wide_19902020 %>%
select(CODIGO,
pH,
DBO,
E_coli,
nitro_amon,
nitro_kjeldahl,
nitro_total,
fosforo_total,
temp_agua,
turbidez,
solidos_totais,
oxigenio_dissolvido,
Condutividade)
write.csv(parametros_IQA,
"./parametros_IQA.csv",
row.names = FALSE)
plan_wide_19902020 %>%
select(starts_with("IQA_^")) %>%
mutate(
TESTANDOIQA = prod()
)## # A tibble: 1,179 x 10
## `IQA_^OD` IQA_^temp~1 IQA_^~2 IQA_^~3 IQA_^~4 IQA_^~5 IQA_^~6 IQA_^~7 IQA_^~8
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2.13 1.58 1.92 1.72 1.18 1.57 1.54 1.39 1.42
## 2 2.15 1.58 1.78 1.71 1.18 1.56 1.55 1.39 1.43
## 3 2.09 1.58 1.85 1.70 1.27 1.50 1.44 1.42 1.42
## 4 2.15 1.58 1.86 1.68 1.12 1.58 1.54 1.38 1.43
## 5 2.18 1.58 1.80 1.72 1.12 1.57 1.53 1.39 1.42
## 6 2.15 1.58 1.84 1.70 1.07 1.58 1.57 1.40 1.43
## 7 2.10 1.58 1.78 1.70 1.15 1.57 1.51 1.41 1.43
## 8 2.08 1.58 1.89 1.70 1.12 1.57 1.52 1.39 1.41
## 9 2.09 1.58 1.86 1.68 1.15 1.56 1.49 1.40 1.43
## 10 2.13 1.58 1.83 1.72 1.07 1.57 1.55 1.38 1.42
## # ... with 1,169 more rows, 1 more variable: TESTANDOIQA <dbl>, and abbreviated
## # variable names 1: `IQA_^temp_agua`, 2: `IQA_^coli`, 3: `IQA_^pH`,
## # 4: `IQA_^DBO`, 5: `IQA_^NitroTot`, 6: `IQA_^Ptot`, 7: `IQA_^Turb`,
## # 8: `IQA_^Sól_Tot`
## # i Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
# library(performance)
# modelo <- plan_wide_19902020 %>%
# select(CODIGO, oxigenio_dissolvido, periodo) %>%
# group_by(CODIGO, periodo) %>%
# lm() %>%
# performance::check_distribution()
# # lm()
#
# check_model(modelo)
# performance::check_autocorrelation(modelo)Time for this code chunk to run: 0.110871076583862
Time for this code chunk to run: 0.00301003456115723
Time for this code chunk to run: 0.00300908088684082
theme_grafs <- function(bg = "white",
coloracao_letra = "black") {
theme(
plot.title =
element_text(
hjust = 0.5,
color = coloracao_letra,
size = 19),
axis.title.x =
# element_text(
# color = coloracao_letra,
# size = 15,
# angle = 0,),
element_blank(),
axis.title.y = element_text(
color = coloracao_letra,
size = 15,
angle = 90),
axis.text.x = element_text(
color = coloracao_letra,
size = 17),
axis.text.y = element_text(
color = coloracao_letra,
size = 17,
angle = 0),
strip.background = element_rect(fill = bg,
linetype = 1,
size = 0.5,
color = "black"),
strip.text = element_text(size = 17),
panel.background = element_rect(fill = bg),
plot.background = element_rect(fill = bg),
plot.margin = margin(l = 5, r = 10,
b = 5, t = 5)
)
}Time for this code chunk to run: 0.00702500343322754
Time for this code chunk to run: 0.0110361576080322
Time for this code chunk to run: 0.00601816177368164
Time for this code
chunk to run: 1.57437109947205
Time for this code
chunk to run: 0.646159887313843
Time
for this code chunk to run: 0.611310005187988
Time
for this code chunk to run: 0.608278036117554
grid.arrange(od_p1, od_p2, od_p3, ncol = 3)Time for this code
chunk to run: 1.55697798728943
ggsave("od.png",
units = c("px"),
width = 4500,
height = 2993,
plot = od,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("od_p1.png",
plot = od_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("od_p2.png",
plot = od_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("od_p3.png",
plot = od_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("od_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(od_p1, od_p2, od_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time for
this code chunk to run: 5.9363100528717
Time for this code chunk to run: 0.00601792335510254
Time
for this code chunk to run: 0.616351127624512
Time
for this code chunk to run: 0.602015972137451
Time
for this code chunk to run: 0.517046928405762
grid.arrange(iqaod_p1, iqaod_p2, iqaod_p3, ncol = 3)Time
for this code chunk to run: 1.92508101463318
## # A tibble: 7 x 8
## par `87398500` `87398900` `87398950` `87398980` `87405500` 874069~1 87409~2
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 min 0.8 2 2.5 4.2 0.1 0.1 0.1
## 2 q1 4.9 5.6 4.4 6 1.9 0.25 1.4
## 3 median 6.4 6.9 5.95 6.3 4.2 2.6 2.9
## 4 mean 5.99 6.78 5.98 7.01 4.22 2.98 3.60
## 5 q3 7.3 8 7.1 8.2 6 5 5.65
## 6 max 10.8 10.5 10.3 12.1 19.9 10.2 11.1
## 7 n 101 101 68 30 97 32 65
## # ... with abbreviated variable names 1: `87406900`, 2: `87409900`
## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.4 3.5 4.9 5.01 6.65 10.9
## 2 87398900 1.9 4 5.5 5.33 6.6 12
## 3 87398950 1.7 3.2 5.3 5.06 6.18 8.9
## 4 87398980 1.2 3.8 5.6 5.38 6.6 9.2
## 5 87405500 0.2 1.4 2.55 3.28 4 14.2
## 6 87406900 0 1.1 1.9 2.59 3.15 16
## 7 87409900 0 0.7 2.3 3.12 3.7 10.6
## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.38 3.11 4.41 4.57 6.2 12.4
## 2 87398900 3.52 5.25 5.96 6.61 7.3 13.8
## 3 87398950 1.62 3.68 4.92 5.28 6.64 11.9
## 4 87398980 3.37 5.5 6.17 6.48 7.14 13.1
## 5 87405500 0.2 1.3 2.53 2.83 3.66 9.8
## 6 87406900 0.1 0.865 2.4 2.43 3.05 9.1
## 7 87409900 0.1 0.92 2.03 2.43 3.5 8.1
Time for this code chunk to run: 0.379782915115356
(dbo <- ggplot(plan_wide_19902020,
aes(x = CODIGO,
y = DBO))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=10,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=5,
ymax=10,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3,
ymax=5,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Demanda Bioquímica de Oxigênio no período 1990-2020",
x="Estação",
y="mg/L")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(1,100),
trans = "log10")+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 60 rows containing non-finite values (stat_boxplot).
## Removed 60 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 22 rows containing missing values (position_quasirandom).
## Warning: Removed 30 rows containing missing values (position_quasirandom).
## Warning: Removed 8 rows containing missing values (position_quasirandom).
Time for
this code chunk to run: 1.4144811630249
Time
for this code chunk to run: 0.877213954925537
Time
for this code chunk to run: 0.62509298324585
Time
for this code chunk to run: 0.534617900848389
Time
for this code chunk to run: 0.964075088500977
Time
for this code chunk to run: 0.878823041915894
Time
for this code chunk to run: 0.600008010864258
grid.arrange(dbo_p1, dbo_p2, dbo_p3, ncol = 3)Time
for this code chunk to run: 2.24644088745117
(sum_dbo_p1 <- plan_wide_19902020 %>%
select(CODIGO, DBO, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(DBO,
na.rm = TRUE),
q1 =
quantile(DBO, 0.25,
na.rm = TRUE),
median =
median(DBO,
na.rm = TRUE),
mean =
mean(DBO,
na.rm= TRUE),
q3 =
quantile(DBO, 0.75,
na.rm = TRUE),
max =
max(DBO,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 1 1 2 1.86 2 13
## 2 87398900 1 1 1 1.52 2 6
## 3 87398950 1 1 1 1.66 2 6
## 4 87398980 1 1 1 1.13 1 2
## 5 87405500 1 2 3 5.37 5 64
## 6 87406900 1 4 5 9 11 26
## 7 87409900 2 3 4 6.97 9.5 31
(sum_dbo_p2 <- plan_wide_19902020 %>%
select(CODIGO, DBO, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(DBO,
na.rm = TRUE),
q1 =
quantile(DBO, 0.25,
na.rm = TRUE),
median =
median(DBO,
na.rm = TRUE),
mean =
mean(DBO,
na.rm= TRUE),
q3 =
quantile(DBO, 0.75,
na.rm = TRUE),
max =
max(DBO,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 1 1 1 1.58 2 5
## 2 87398900 1 1 1 1.40 2 5
## 3 87398950 1 1 1 1.66 2 5
## 4 87398980 1 1 1 1.30 1 5
## 5 87405500 1 2 4 4.67 6.5 14
## 6 87406900 1 3 5 6.53 8 28
## 7 87409900 1 3 6 6.31 9 15
(sum_dbo_p3 <- plan_wide_19902020 %>%
select(CODIGO, DBO, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(DBO,
na.rm = TRUE),
q1 =
quantile(DBO, 0.25,
na.rm = TRUE),
median =
median(DBO,
na.rm = TRUE),
mean =
mean(DBO,
na.rm= TRUE),
q3 =
quantile(DBO, 0.75,
na.rm = TRUE),
max =
max(DBO,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 1 1 1.5 2.15 3 7
## 2 87398900 1 1 1 1.51 2 5
## 3 87398950 1 1 2 2.65 2 18
## 4 87398980 1 1 1 1.32 2 2
## 5 87405500 1 3 4 5.28 6.25 21
## 6 87406900 1 3 5 6.58 10 24
## 7 87409900 1 3 4.5 6.18 8 18
Time for this code chunk to run: 0.290477991104126
ggsave("dbo.png",
units = c("px"),
width = 4500,
height = 2993,
plot = dbo,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("dbo_p1.png",
plot = dbo_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("dbo_p2.png",
plot = dbo_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("dbo_p3.png",
plot = dbo_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("dbo_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(dbo_p1, dbo_p2, dbo_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 6.95932197570801
(ptot <- ggplot(plan_wide_19902020,
aes(CODIGO,
fosforo_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Fósforo total no período 1990-2020",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$fosforo_total, na.rm = TRUE),
max(plan_wide_19902020$fosforo_total), na.rm = TRUE),
trans = "log10")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 134 rows containing non-finite values (stat_boxplot).
## Removed 134 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 47 rows containing missing values (position_quasirandom).
## Warning: Removed 31 rows containing missing values (position_quasirandom).
## Warning: Removed 56 rows containing missing values (position_quasirandom).
Time for this code chunk to
run: 1.45419406890869
(ptot_p1<-ggplot(plan_wide_19902020%>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
fosforo_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Fósforo total no período 1990-2000",
x="Estação",
y="mg/L")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$fosforo_total, na.rm = TRUE),
max(plan_wide_19902020$fosforo_total), na.rm = TRUE),
trans = "log10")+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.716385126113892
(ptot_p2 <- ggplot(plan_wide_19902020%>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
fosforo_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Fósforo total no período 2000-2010",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$fosforo_total, na.rm = TRUE),
max(plan_wide_19902020$fosforo_total), na.rm = TRUE),
trans = "log10")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.742863178253174
(ptot_p3 <- ggplot(plan_wide_19902020%>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
fosforo_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.15,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0.1,
ymax=0.15,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=0.1,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Fósforo total no período 2010-2020",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.03,0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$fosforo_total, na.rm = TRUE),
max(plan_wide_19902020$fosforo_total), na.rm = TRUE),
trans = "log10")+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.568916082382202
grid.arrange(ptot_p1, ptot_p2, ptot_p3, ncol = 3)Time
for this code chunk to run: 1.8001549243927
(sum_ptot_p1 <- plan_wide_19902020 %>%
select(CODIGO, fosforo_total, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(fosforo_total, na.rm = TRUE),
q1 =
quantile(fosforo_total, 0.25, na.rm = TRUE),
median =
median(fosforo_total, na.rm = TRUE),
mean =
mean(fosforo_total, na.rm= TRUE),
q3 =
quantile(fosforo_total, 0.75, na.rm = TRUE),
max =
max(fosforo_total, na.rm = TRUE)))## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.0097 0.0593 0.0881 0.123 0.14 0.863
## 2 87398900 0.0023 0.0468 0.0678 0.0747 0.0883 0.247
## 3 87398950 0.0202 0.0544 0.0737 0.0751 0.0904 0.179
## 4 87398980 0.01 0.0254 0.0547 0.0708 0.114 0.189
## 5 87405500 0.017 0.171 0.281 0.417 0.492 2.32
## 6 87406900 0.156 0.270 0.508 0.785 1.07 2.79
## 7 87409900 0.107 0.258 0.384 0.489 0.712 1.53
(sum_ptot_p2 <- plan_wide_19902020 %>%
select(CODIGO, fosforo_total, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(fosforo_total, na.rm = TRUE),
q1 =
quantile(fosforo_total, 0.25, na.rm = TRUE),
median =
median(fosforo_total, na.rm = TRUE),
mean =
mean(fosforo_total, na.rm= TRUE),
q3 =
quantile(fosforo_total, 0.75, na.rm = TRUE),
max =
max(fosforo_total, na.rm = TRUE)))## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.025 0.094 0.131 0.148 0.16 0.637
## 2 87398900 0.015 0.0764 0.104 0.140 0.164 0.646
## 3 87398950 0.036 0.116 0.171 0.180 0.207 0.485
## 4 87398980 0.0115 0.052 0.076 0.101 0.103 1
## 5 87405500 0.046 0.261 0.406 0.547 0.681 1.98
## 6 87406900 0.056 0.338 0.599 0.752 0.967 3.49
## 7 87409900 0.043 0.325 0.624 0.677 0.989 1.57
(sum_ptot_p3 <- plan_wide_19902020 %>%
select(CODIGO, fosforo_total, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(fosforo_total, na.rm = TRUE),
q1 =
quantile(fosforo_total, 0.25, na.rm = TRUE),
median =
median(fosforo_total, na.rm = TRUE),
mean =
mean(fosforo_total, na.rm= TRUE),
q3 =
quantile(fosforo_total, 0.75, na.rm = TRUE),
max =
max(fosforo_total, na.rm = TRUE)))## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.061 0.118 0.163 0.166 0.186 0.381
## 2 87398900 0.057 0.0935 0.130 0.163 0.168 0.444
## 3 87398950 0.07 0.132 0.156 0.292 0.221 3.11
## 4 87398980 0.019 0.0625 0.106 0.144 0.170 0.59
## 5 87405500 0.013 0.187 0.332 0.361 0.45 0.803
## 6 87406900 0.089 0.254 0.364 0.448 0.560 1.26
## 7 87409900 0.203 0.259 0.369 0.488 0.564 1.7
Time for this code chunk to run: 0.266400098800659
ggsave("ptot.png",
units = c("px"),
width = 4500,
height = 2993,
plot = ptot,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ptot_p1.png",
plot = ptot_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ptot_p2.png",
plot = ptot_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ptot_p3.png",
plot = ptot_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ptot_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(ptot_p1, ptot_p2, ptot_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 6.5336799621582
ecoli__class <- function() {
list(annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb") #classe 1
)
}
(ecoli <- ggplot(plan_wide_19902020,
aes(CODIGO,
E_coli))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Escherichia coli no período 1990-2020",
x="Estação",
y="NMP/100mL")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
# n.breaks = 9,
n.breaks = 6,
limits = c(min(plan_wide_19902020$E_coli, na.rm = TRUE),
max(plan_wide_19902020$E_coli, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()+
theme(
axis.text.y = element_text(
angle = 90,
# size=15,
# face=2
)
)
)Time for this
code chunk to run: 1.39499497413635
(ecoli_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
E_coli))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Escherichia coli no período 1990-2000",
x="Estação",
y="NMP/100mL")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$E_coli, na.rm = TRUE),
max(plan_wide_19902020$E_coli, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.686120986938477
(ecoli_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
E_coli))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Escherichia coli no período 2000-2010",
x="Estação",
y="NMP/100mL")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$E_coli, na.rm = TRUE),
max(plan_wide_19902020$E_coli, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.675113916397095
(ecoli_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
E_coli))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3200,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=800,
ymax=3200,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=160,
ymax=800,
alpha=1,
fill="#70c18c")+ #classe 2
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=160,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Escherichia coli no período 2010-2020",
x="Estação",
y="NMP/100mL")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$E_coli, na.rm = TRUE),
max(plan_wide_19902020$E_coli, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.633121013641357
grid.arrange(ecoli_p1, ecoli_p2, ecoli_p3, ncol = 3)Time
for this code chunk to run: 1.75200986862183
(sum_ecoli_p1 <- plan_wide_19902020 %>%
select(CODIGO, E_coli, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(E_coli,
na.rm = TRUE),
q1 =
quantile(E_coli, 0.25,
na.rm = TRUE),
median =
median(E_coli,
na.rm = TRUE),
mean =
mean(E_coli,
na.rm= TRUE),
q3 =
quantile(E_coli, 0.75,
na.rm = TRUE),
max =
max(E_coli,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 32 136 240 854. 720 19200
## 2 87398900 16 68 160 548. 480 7760
## 3 87398950 2.4 12.8 268 4039. 10000 28000
## 4 87398980 4 160 243. 2907. 446 25600
## 5 87405500 1.6 12.8 24 545. 128 18400
## 6 87406900 13.6 61.6 192 718. 414 12800
## 7 87409900 2.4 12.8 64 97.7 128 720
(sum_ecoli_p2 <- plan_wide_19902020 %>%
select(CODIGO, E_coli, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(E_coli,
na.rm = TRUE),
q1 =
quantile(E_coli, 0.25,
na.rm = TRUE),
median =
median(E_coli,
na.rm = TRUE),
mean =
mean(E_coli,
na.rm= TRUE),
q3 =
quantile(E_coli, 0.75,
na.rm = TRUE),
max =
max(E_coli,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 21.6 91 150 1335. 308 27200
## 2 87398900 11 70 133. 444. 414. 2600
## 3 87398950 20 400 720 935. 1120 5500
## 4 87398980 24 110. 195 410. 289. 8800
## 5 87405500 4.7 162 2400 25445. 12950 490000
## 6 87406900 8 172 12800 66370. 62300 650000
## 7 87409900 16 7355. 35500 72440. 68750 460000
(sum_ecoli_p3 <- plan_wide_19902020 %>%
select(CODIGO, E_coli, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(E_coli,
na.rm = TRUE),
q1 =
quantile(E_coli, 0.25,
na.rm = TRUE),
median =
median(E_coli,
na.rm = TRUE),
mean =
mean(E_coli,
na.rm= TRUE),
q3 =
quantile(E_coli, 0.75,
na.rm = TRUE),
max =
max(E_coli,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 90 155. 260 409. 451 2420
## 2 87398900 10 52.8 107 245. 313 1553.
## 3 87398950 108. 250 487 1424. 1553. 10462
## 4 87398980 40.8 140. 242. 529. 738. 2400
## 5 87405500 632 8965 19232. 109992. 70750 1400000
## 6 87406900 1440 23100 34500 230828. 140500 3400000
## 7 87409900 2000 20100 38400 83128. 83680 345000
Time for this code chunk to run: 0.193144798278809
ggsave("ecoli.png",
plot = ecoli,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ecoli_p1.png",
plot = ecoli_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ecoli_p2.png",
plot = ecoli_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ecoli_p3.png",
plot = ecoli_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("ecoli_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(ecoli_p1, ecoli_p2, ecoli_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 7.07270789146423
(namon <- ggplot(plan_wide_19902020,
aes(CODIGO,
nitro_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Nitrogênio amoniacal no período 1990-2020",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$nitro_total, na.rm = TRUE),
max(plan_wide_19902020$nitro_total, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time for this code
chunk to run: 1.5649778842926
(namon_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
nitro_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Nitrogênio amoniacal no período 1990-2000",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$nitro_total, na.rm = TRUE),
max(plan_wide_19902020$nitro_total, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.671724081039429
(namon_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
nitro_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Nitrogênio amoniacal no período 2000-2010",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$nitro_total, na.rm = TRUE),
max(plan_wide_19902020$nitro_total, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.669715881347656
(namon_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
nitro_total))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=13.3,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=3.7,
ymax=13.3,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=3.7,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Nitrogênio amoniacal no período 2010-2020",
x="Estação",
y="mg/L")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 9,
limits = c(min(plan_wide_19902020$nitro_total, na.rm = TRUE),
max(plan_wide_19902020$nitro_total, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = .001,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.578238964080811
grid.arrange(namon_p1, namon_p2, namon_p3, ncol = 3)Time
for this code chunk to run: 2.00533390045166
(sum_namon_p1 <- plan_wide_19902020 %>%
select(CODIGO, nitro_total, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(nitro_total,
na.rm = TRUE),
q1 =
quantile(nitro_total, 0.25,
na.rm = TRUE),
median =
median(nitro_total,
na.rm = TRUE),
mean =
mean(nitro_total,
na.rm= TRUE),
q3 =
quantile(nitro_total, 0.75,
na.rm = TRUE),
max =
max(nitro_total,
na.rm = TRUE),
n =
length(nitro_total)
)
)## # A tibble: 7 x 8
## CODIGO min q1 median mean q3 max n
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 87398500 0.44 0.842 1.00 1.22 1.34 3.81 101
## 2 87398900 0.22 0.82 1 1.09 1.25 4.86 101
## 3 87398950 0.51 0.83 1.02 1.06 1.19 2.16 68
## 4 87398980 0.549 0.68 0.755 0.872 1.01 1.85 30
## 5 87405500 0.51 1.53 2.94 5.27 6.77 21.6 97
## 6 87406900 1.34 2.60 4.56 7.58 11.2 29.1 32
## 7 87409900 0.5 1.98 4.29 5.18 7.01 19.6 65
(sum_namon_p2 <- plan_wide_19902020 %>%
select(CODIGO, nitro_total, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(nitro_total,
na.rm = TRUE),
q1 =
quantile(nitro_total, 0.25,
na.rm = TRUE),
median =
median(nitro_total,
na.rm = TRUE),
mean =
mean(nitro_total,
na.rm= TRUE),
q3 =
quantile(nitro_total, 0.75,
na.rm = TRUE),
max =
max(nitro_total,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.18 0.885 0.992 1.80 1.46 23.2
## 2 87398900 0.48 0.894 1.13 1.38 1.57 7.92
## 3 87398950 0.57 1.26 1.45 1.43 1.71 1.98
## 4 87398980 0.19 0.685 0.79 1.05 1.10 5.2
## 5 87405500 0.968 2 3.29 5.45 6.60 21.7
## 6 87406900 0.77 2.4 4.54 7.30 10.2 39.1
## 7 87409900 1.62 2.5 6.97 7.92 10.6 21.5
(sum_namon_p3 <- plan_wide_19902020 %>%
select(CODIGO, nitro_total, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(nitro_total,
na.rm = TRUE),
q1 =
quantile(nitro_total, 0.25,
na.rm = TRUE),
median =
median(nitro_total,
na.rm = TRUE),
mean =
mean(nitro_total,
na.rm= TRUE),
q3 =
quantile(nitro_total, 0.75,
na.rm = TRUE),
max =
max(nitro_total,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 0.222 0.89 1.11 1.24 1.41 2.56
## 2 87398900 0.095 0.883 1.02 1.29 1.40 4.25
## 3 87398950 0.612 1.04 1.43 1.90 2.06 9.5
## 4 87398980 0.216 0.973 1.12 1.22 1.58 2.32
## 5 87405500 1.12 2.03 3.14 4.50 5.93 22.0
## 6 87406900 1.37 2.40 5.58 6.47 7.58 25
## 7 87409900 1.11 3 6.15 7.29 7.75 36
Time for this code chunk to run: 0.232770919799805
ggsave("namon.png",
units = c("px"),
width = 4500,
height = 2993,
plot = namon,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("namon_p1.png",
plot = namon_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("namon_p2.png",
plot = namon_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("namon_p3.png",
plot = namon_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("namon_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(namon_p1, namon_p2, namon_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 5.81579899787903
(turb <- ggplot(plan_wide_19902020,
aes(CODIGO,
turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Turbidez no período 1990-2020",
x="Estação",
y="UNT")+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.05)),
n.breaks = 16,
limits = c(min(plan_wide_19902020$turbidez, na.rm = TRUE),
# 500
max(plan_wide_19902020$turbidez, na.rm = TRUE)
),
# trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time for this code chunk
to run: 1.44730496406555
(turb_line <- plan_wide_19902020 %>%
filter(ANO_COLETA > "1990" &
ANO_COLETA <= "2020") %>%
select(CODIGO, turbidez, DATA_COLETA, periodo) %>%
group_by(CODIGO) %>%
ggplot(
aes(x = DATA_COLETA,
y = turbidez,
color = CODIGO
))+
geom_line(
# aes(color = CODIGO),
na.rm = TRUE)+
geom_point(
# aes(color = CODIGO),
na.rm = TRUE)+
scale_x_date(
limits = as.Date(c(
"1990-01-01",
"2021-01-01"
# NA #pode usar NA também
)),
expand = c(0.0, 0.0),
date_breaks = "10 years",
minor_breaks = "5 years",
date_labels = "%Y",
)+
# geom_smooth(
# # aes(color = CODIGO),
# method = "lm",
# # formula = y ~ poly(x, 2),
# # span = 0.2,
# se = TRUE, #se deixar TRUE gera o intervalo de confiança de 95%
# aes(group = 1),
# alpha =.5,
# na.rm = TRUE,
# size = 0.3,
# # fullrange = TRUE,
# # show.legend = TRUE
# )+
# stat_smooth(
# geom = "smooth",
# # span = 0.2,
# se = FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
# # aes(group = 1),
# # alpha =.5,
# na.rm = TRUE,
# # size = 0.3,
# fullrange = TRUE,
# show.legend = TRUE
# )+
facet_wrap(
~CODIGO,
nrow = 4,
)+
theme_bw()
)Time
for this code chunk to run: 1.48263597488403
(turb_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Turbidez no período 1990-2000",
x="Estação",
y="UNT")+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$turbidez, na.rm = TRUE),
max(plan_wide_19902020$turbidez, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.625974893569946
(turb_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Turbidez no período 2000-2010",
x="Estação",
y="UNT")+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$turbidez, na.rm = TRUE),
max(plan_wide_19902020$turbidez, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.603034019470215
(turb_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
turbidez))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=100,
ymax=Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=40,
ymax=100,
alpha=1,
fill="#fcf7ab")+ #classe 3
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=0,
ymax=40,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Turbidez no período 2010-2020",
x="Estação",
y="UNT")+
scale_y_continuous(expand = expansion(mult = c(0.05, 0.03)),
n.breaks = 8,
limits = c(min(plan_wide_19902020$turbidez, na.rm = TRUE),
max(plan_wide_19902020$turbidez, na.rm = TRUE)),
trans = "log10",
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.593801975250244
grid.arrange(turb_p1, turb_p2, turb_p3, ncol = 3)Time
for this code chunk to run: 1.6898889541626
(sum_turb_p1 <- plan_wide_19902020 %>%
select(CODIGO, turbidez, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(turbidez,
na.rm = TRUE),
q1 =
quantile(turbidez, 0.25,
na.rm = TRUE),
median =
median(turbidez,
na.rm = TRUE),
mean =
mean(turbidez,
na.rm= TRUE),
q3 =
quantile(turbidez, 0.75,
na.rm = TRUE),
max =
max(turbidez,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 6.2 19 34.5 63.5 67 461
## 2 87398900 9 19 49.5 61.5 73.8 460
## 3 87398950 9.6 16 22 33.3 48.8 144
## 4 87398980 16 32.8 43 66.8 90.5 190
## 5 87405500 8.5 23.5 47 47.5 58 159
## 6 87406900 33 54.8 67 77.7 81.5 199
## 7 87409900 5.8 15 25 32.2 48 76
(sum_turb_p2 <- plan_wide_19902020 %>%
select(CODIGO, turbidez, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(turbidez,
na.rm = TRUE),
q1 =
quantile(turbidez, 0.25,
na.rm = TRUE),
median =
median(turbidez,
na.rm = TRUE),
mean =
mean(turbidez,
na.rm= TRUE),
q3 =
quantile(turbidez, 0.75,
na.rm = TRUE),
max =
max(turbidez,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 9 41.2 55.5 71.1 74.2 428
## 2 87398900 39 57 78 107. 116. 475
## 3 87398950 39 47 64 96.5 90 330
## 4 87398980 24 37 50 64.5 87 176
## 5 87405500 32 46 63.5 70.3 76 341
## 6 87406900 35 49 62 69.9 75.5 284
## 7 87409900 40 45 60 70.4 90 151
(sum_turb_p3 <- plan_wide_19902020 %>%
select(CODIGO, turbidez, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(turbidez,
na.rm = TRUE),
q1 =
quantile(turbidez, 0.25,
na.rm = TRUE),
median =
median(turbidez,
na.rm = TRUE),
mean =
mean(turbidez,
na.rm= TRUE),
q3 =
quantile(turbidez, 0.75,
na.rm = TRUE),
max =
max(turbidez,
na.rm = TRUE))
) ## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 8.52 16.4 29 33.3 43 85
## 2 87398900 14.8 39.2 48.3 66.7 73.4 299
## 3 87398950 16 29.9 41 51.6 65 230
## 4 87398980 11 19.4 33.6 39.5 42.2 110.
## 5 87405500 10.0 29.0 41 42.9 54.5 131
## 6 87406900 9.62 23 39 41.2 52 122
## 7 87409900 9.68 22.0 34.0 40.5 47 182.
Time for this code chunk to run: 0.18913197517395
ggsave("turb.png",
units = c("px"),
width = 4500,
height = 2993,
plot = turb,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("turb_p1.png",
plot = turb_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("turb_p2.png",
plot = turb_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("turb_p3.png",
plot = turb_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("turb_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(turb_p1, turb_p2, turb_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 6.32214689254761
(pH <- ggplot(plan_wide_19902020,
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "pH no período 1990-2020",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time for this code chunk to
run: 1.44370412826538
(pH_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "pH no período 1990-2000",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.731919050216675
(pH_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "pH no período 2000-2010",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.652501821517944
(pH_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
pH))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=6,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=9,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=6,
ymax=9,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "pH no período 2010-2020",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.01)),
n.breaks = 8,
limits = c(4,11),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.636536121368408
grid.arrange(pH_p1, pH_p2, pH_p3, ncol = 3)Time
for this code chunk to run: 1.85151791572571
(sum_pH_p1 <- plan_wide_19902020 %>%
select(CODIGO, pH, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(pH,
na.rm = TRUE),
q1 =
quantile(pH, 0.25,
na.rm = TRUE),
median =
median(pH,
na.rm = TRUE),
mean =
mean(pH,
na.rm= TRUE),
q3 =
quantile(pH, 0.75,
na.rm = TRUE),
max =
max(pH,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 5 6.18 6.59 6.51 6.82 7.9
## 2 87398900 5.2 6 6.3 6.33 6.63 7.9
## 3 87398950 5.4 6.29 6.4 6.49 6.72 8.1
## 4 87398980 5.3 5.93 6.2 6.16 6.3 7.3
## 5 87405500 5 6.3 6.4 6.47 6.7 9.3
## 6 87406900 5.5 6.18 6.45 6.43 6.8 7.3
## 7 87409900 4.5 6.2 6.4 6.44 6.7 7.4
(sum_pH_p2 <- plan_wide_19902020 %>%
select(CODIGO, pH, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(pH,
na.rm = TRUE),
q1 =
quantile(pH, 0.25,
na.rm = TRUE),
median =
median(pH,
na.rm = TRUE),
mean =
mean(pH,
na.rm= TRUE),
q3 =
quantile(pH, 0.75,
na.rm = TRUE),
max =
max(pH,
na.rm = TRUE))
) ## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 5.3 6.3 6.6 6.59 6.88 7.9
## 2 87398900 5.5 6.4 6.65 6.63 6.9 7.5
## 3 87398950 6 6.6 6.8 6.89 7.25 7.6
## 4 87398980 5.8 6.3 6.5 6.63 7 7.5
## 5 87405500 5.2 6.4 6.6 6.68 6.9 8.3
## 6 87406900 5.5 6.4 6.7 6.66 6.9 8.6
## 7 87409900 5.8 6.5 6.8 6.77 7 8.4
(sum_pH_p3 <- plan_wide_19902020 %>%
select(CODIGO, pH, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(pH,
na.rm = TRUE),
q1 =
quantile(pH, 0.25,
na.rm = TRUE),
median =
median(pH,
na.rm = TRUE),
mean =
mean(pH,
na.rm= TRUE),
q3 =
quantile(pH, 0.75,
na.rm = TRUE),
max =
max(pH,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 5.47 6.28 6.42 6.47 6.60 7.3
## 2 87398900 5.68 6.36 6.5 6.57 6.84 7.4
## 3 87398950 5.71 6.28 6.46 6.46 6.68 7
## 4 87398980 5.42 6.10 6.36 6.39 6.6 7.2
## 5 87405500 5.64 6.34 6.5 6.49 6.7 7.01
## 6 87406900 5.6 6.4 6.48 6.51 6.77 7.3
## 7 87409900 5.59 6.46 6.6 6.57 6.76 7.2
Time for this code chunk to run: 0.182004928588867
ggsave("pH.png",
units = c("px"),
width = 4500,
height = 2993,
plot = pH,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("pH_p1.png",
plot = pH_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("pH_p2.png",
plot = pH_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("pH_p3.png",
plot = pH_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("pH_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(pH_p1, pH_p2, pH_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time for
this code chunk to run: 6.2132830619812
(SolTot <- ggplot(plan_wide_19902020,
aes(CODIGO,
solidos_totais))+
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 500, ymax = Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Sólidos totais no período 1990-2020",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$solidos_totais, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time for this code
chunk to run: 1.43013286590576
(SolTot_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000"),
aes(CODIGO,
solidos_totais))+
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 500, ymax = Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Sólidos totais no período 1990-2000",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$solidos_totais, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.660574197769165
(SolTot_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
solidos_totais))+
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 500, ymax = Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Sólidos totais no período 2000-2010",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$solidos_totais, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.638144969940186
(SolTot_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
solidos_totais))+
annotate("rect",
xmin = -Inf, xmax = Inf,
ymin = 500, ymax = Inf,
alpha=1,
fill="#ac5079")+ #>pior classe
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Sólidos totais no período 2010-2020",
x="Estação",
y="")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$solidos_totais, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.611053943634033
grid.arrange(SolTot_p1, SolTot_p2, SolTot_p3, ncol = 3)Time
for this code chunk to run: 2.3169219493866
(sum_SolTot_p1 <- plan_wide_19902020 %>%
select(CODIGO, solidos_totais, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(solidos_totais,
na.rm = TRUE),
q1 =
quantile(solidos_totais, 0.25,
na.rm = TRUE),
median =
median(solidos_totais,
na.rm = TRUE),
mean =
mean(solidos_totais,
na.rm= TRUE),
q3 =
quantile(solidos_totais, 0.75,
na.rm = TRUE),
max =
max(solidos_totais,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 46 84.5 95 122. 120 510
## 2 87398900 18 74.5 97 111. 122. 474
## 3 87398950 10 76.5 91 90.9 106. 155
## 4 87398980 48 63.5 81.5 104. 126. 337
## 5 87405500 70 101 121 133. 151 361
## 6 87406900 89 118 155 165. 210 279
## 7 87409900 20 99.5 122 128. 143 381
(sum_SolTot_p2 <- plan_wide_19902020 %>%
select(CODIGO, solidos_totais, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(solidos_totais,
na.rm = TRUE),
q1 =
quantile(solidos_totais, 0.25,
na.rm = TRUE),
median =
median(solidos_totais,
na.rm = TRUE),
mean =
mean(solidos_totais,
na.rm= TRUE),
q3 =
quantile(solidos_totais, 0.75,
na.rm = TRUE),
max =
max(solidos_totais,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 28 80 100 111. 123. 412
## 2 87398900 42 82 102. 128. 140. 489
## 3 87398950 46 94.2 108. 126. 127. 318
## 4 87398980 40 61 77 85.3 96 228
## 5 87405500 48 102 133 148. 170. 522
## 6 87406900 50 109 134. 154. 170. 670
## 7 87409900 56 112. 156 167. 190. 599
(sum_SolTot_p3 <- plan_wide_19902020 %>%
select(CODIGO, solidos_totais, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(solidos_totais,
na.rm = TRUE),
q1 =
quantile(solidos_totais, 0.25,
na.rm = TRUE),
median =
median(solidos_totais,
na.rm = TRUE),
mean =
mean(solidos_totais,
na.rm= TRUE),
q3 =
quantile(solidos_totais, 0.75,
na.rm = TRUE),
max =
max(solidos_totais,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 61 69 90 82.8 96 101
## 2 87398900 41 77 104 120. 127 308
## 3 87398950 45 93 101 109. 117 221
## 4 87398980 55 62.8 80 79.9 95 109
## 5 87405500 83 89.2 108. 124. 162. 195
## 6 87406900 50 106 117 135. 163 246
## 7 87409900 75 103 115 131. 145 251
Time for this code chunk to run: 0.270380973815918
ggsave("SolTot.png",
units = c("px"),
width = 4500,
height = 2993,
plot = SolTot,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("SolTot_p1.png",
plot = SolTot_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("SolTot_p2.png",
plot = SolTot_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("SolTot_p3.png",
plot = SolTot_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("SolTot_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(SolTot_p1, SolTot_p2, SolTot_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 7.39859509468079
Time for this code chunk to
run: 1.22835898399353
Time
for this code chunk to run: 0.605374813079834
Time
for this code chunk to run: 0.581258058547974
Time
for this code chunk to run: 0.509715795516968
grid.arrange(iqa_p1, iqa_p2, iqa_p3, ncol = 3)Time
for this code chunk to run: 1.44455504417419
(sum_IQA_p1 <- plan_wide_19902020 %>%
select(CODIGO, IQA, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(IQA,
na.rm = TRUE),
q1 =
quantile(IQA, 0.25,
na.rm = TRUE),
median =
median(IQA,
na.rm = TRUE),
mean =
mean(IQA,
na.rm= TRUE),
q3 =
quantile(IQA, 0.75,
na.rm = TRUE),
max =
max(IQA,
na.rm = TRUE),
n =
length(IQA)
)
)## # A tibble: 7 x 8
## CODIGO min q1 median mean q3 max n
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 87398500 27.0 35.7 40.9 40.7 46.2 52.2 101
## 2 87398900 27.8 37.9 42.9 43.0 48.0 58.5 101
## 3 87398950 32.8 36.8 41.4 43.2 48.6 61.9 68
## 4 87398980 29.2 35.8 40.4 40.3 44.8 51.9 30
## 5 87405500 24.8 34.9 41.2 40.3 46.9 57.6 97
## 6 87406900 24.7 31.3 37.8 37.4 44.4 49.0 32
## 7 87409900 23.6 31.9 37.1 38.8 46.2 55.4 65
(sum_IQA_p2 <- plan_wide_19902020 %>%
select(CODIGO, IQA, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(IQA,
na.rm = TRUE),
q1 =
quantile(IQA, 0.25,
na.rm = TRUE),
median =
median(IQA,
na.rm = TRUE),
mean =
mean(IQA,
na.rm= TRUE),
q3 =
quantile(IQA, 0.75,
na.rm = TRUE),
max =
max(IQA,
na.rm = TRUE),
n =
length(IQA)
)
)## # A tibble: 7 x 8
## CODIGO min q1 median mean q3 max n
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 87398500 27.8 34.6 40.0 39.5 43.5 48.7 75
## 2 87398900 28.5 35.1 37.6 38.3 40.6 48.5 77
## 3 87398950 21.1 29.4 32.7 32.8 36.8 44.0 30
## 4 87398980 24.5 35.7 39.4 39.5 43.4 52.1 66
## 5 87405500 19.8 28.7 31.5 31.9 35.7 48.8 78
## 6 87406900 17.1 25.3 29.0 29.5 32.8 44.1 79
## 7 87409900 16.2 20.5 26.1 25.0 29.8 33.1 31
(sum_IQA_p3 <- plan_wide_19902020 %>%
select(CODIGO, IQA, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
# ?as_factor(CODIGO) %>%
group_by(CODIGO) %>%
summarize(
min =
min(IQA,
na.rm = TRUE),
q1 =
quantile(IQA, 0.25,
na.rm = TRUE),
median =
median(IQA,
na.rm = TRUE),
mean =
mean(IQA,
na.rm= TRUE),
q3 =
quantile(IQA, 0.75,
na.rm = TRUE),
max =
max(IQA,
na.rm = TRUE),
n =
length(IQA),
NAs =
sum(is.na(IQA))
) %>%
mutate(
"%NA" = NAs/n*100
)
)## # A tibble: 7 x 10
## CODIGO min q1 median mean q3 max n NAs `%NA`
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <int> <dbl>
## 1 87398500 40.2 42.5 45.4 44.2 45.5 47.2 34 29 85.3
## 2 87398900 34.1 38.6 41.2 40.2 42.9 44.4 36 32 88.9
## 3 87398950 36.7 39.5 42.4 41.5 44.4 44.6 35 31 88.6
## 4 87398980 40.0 40.0 40.0 40.0 40.0 40.0 28 27 96.4
## 5 87405500 30.8 31.6 32.5 32.5 33.3 34.1 33 31 93.9
## 6 87406900 22.9 24.4 25.9 25.3 26.5 27.2 35 32 91.4
## 7 87409900 24.1 25.1 27.3 26.9 28.2 29.7 37 32 86.5
Time for this code chunk to run: 0.215734004974365
ggsave("iqa.png",
units = c("px"),
width = 4500,
height = 2993,
plot = iqa,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("iqa_p1.png",
plot = iqa_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("iqa_p2.png",
plot = iqa_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("iqa_p3.png",
plot = iqa_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("iqa_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(iqa_p1, iqa_p2, iqa_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 5.97772717475891
parametros_IQA %>%
select(-CODIGO) %>%
ggcorr(
method = "complete.obs",
# "pearson",
# "pairwise",
name = "Correlação",
label = TRUE,
label_alpha = TRUE,
digits = 3,
low = "#3B9AB2",
mid = "#EEEEEE",
high = "#F21A00",
# palette = "RdYlBu",
layout.exp = 0,
legend.position = "left",
label_round = 3,
)correlação-parametros-qualidade-agua-gravataí no período 1990-2020
# Gráfico das correlações entre todos os parâmetros com significância
correl_IQA <- parametros_IQA %>%
select(-CODIGO) %>%
ggpairs(title = "Correlação entre parâmetros que compõem o IQA",
axisLabels = "show")Time for this code chunk to run: 0.653198003768921
(cond_elet <- ggplot(plan_wide_19902020,
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
facet_wrap(~periodo)+
labs(title = "Condutividade elétrica no período 1990-2020",
x="Estação",
y="µmhos/cm")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time for
this code chunk to run: 1.62007188796997
(cond_elet_p1 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Condutividade elétrica no período 1990-2000",
x="Estação",
y="µmhos/cm")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.645016193389893
(cond_elet_p2 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010"),
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Condutividade elétrica no período 2000-2010",
x="Estação",
y="µmhos/cm")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.637626171112061
(cond_elet_p3 <- ggplot(plan_wide_19902020 %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020"),
aes(CODIGO,
Condutividade))+
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=500,
ymax=Inf,
alpha=1,
fill="#eb5661")+ #classe 4
annotate("rect",
xmin=-Inf,
xmax=Inf,
ymin=-Inf,
ymax=500,
alpha=1,
fill="#8dcdeb")+ #classe 1
stat_boxplot(geom = 'errorbar',
width=0.3,
position = position_dodge(width = 0.65))+
geom_boxplot(fill='#F8F8FF',
color="black",
outlier.shape = NA, #se deixar NA fica só o jitter, se não, deixa 1
width= 0.7)+
labs(title = "Condutividade elétrica no período 2010-2020",
x="Estação",
y="µmhos/cm")+
scale_y_continuous(expand = expansion(mult = c(0.01, 0.05)),
n.breaks = 8,
limits = c(0,
max(plan_wide_19902020$Condutividade, na.rm = TRUE)),
labels = scales::number_format(accuracy = 1,
decimal.mark = ",",
big.mark = " "))+
ggbeeswarm::geom_quasirandom(
size = 1.2,
alpha = .25,
width = .07,
)+
scale_x_discrete(limits = c("87398500",
"87398980",
"87398900",
"87398950",
"87405500",
"87406900",
"87409900"),
labels = c("PM1", "PM2", "PM3", "PM4", "PM5", "PM6", "PM7")
)+
geom_smooth(method = "lm",
se=FALSE, #se deixar TRUE gera o intervalo de confiança de 95%
aes(group=1),
alpha=.5,
na.rm = TRUE,
size = 1)+
theme_grafs()
)Time
for this code chunk to run: 0.547132015228271
grid.arrange(cond_elet_p1, cond_elet_p2, cond_elet_p3, ncol = 3)Time
for this code chunk to run: 1.69333910942078
(sum_cond_elet_p1 <- plan_wide_19902020 %>%
select(CODIGO, Condutividade, ANO_COLETA) %>%
filter(ANO_COLETA>"1990" &
ANO_COLETA<="2000") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Condutividade,
na.rm = TRUE),
q1 =
quantile(Condutividade, 0.25,
na.rm = TRUE),
median =
median(Condutividade,
na.rm = TRUE),
mean =
mean(Condutividade,
na.rm= TRUE),
q3 =
quantile(Condutividade, 0.75,
na.rm = TRUE),
max =
max(Condutividade,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 9.4 51.1 67 75.1 83.2 340
## 2 87398900 10 41.5 51 55.3 64.2 160
## 3 87398950 9 41.5 51.5 60.1 69.5 160
## 4 87398980 11.3 42.4 52.0 53.0 67.0 83.8
## 5 87405500 25 68.7 88.2 130. 170 560
## 6 87406900 52 88.4 133. 193. 256. 576
## 7 87409900 29 80 110. 134. 168. 460
(sum_cond_elet_p2 <- plan_wide_19902020 %>%
select(CODIGO, Condutividade, ANO_COLETA) %>%
filter(ANO_COLETA>"2000" &
ANO_COLETA<="2010") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Condutividade,
na.rm = TRUE),
q1 =
quantile(Condutividade, 0.25,
na.rm = TRUE),
median =
median(Condutividade,
na.rm = TRUE),
mean =
mean(Condutividade,
na.rm= TRUE),
q3 =
quantile(Condutividade, 0.75,
na.rm = TRUE),
max =
max(Condutividade,
na.rm = TRUE))
)## # A tibble: 7 x 7
## CODIGO min q1 median mean q3 max
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 87398500 11.9 67.0 82.6 84.8 102. 164.
## 2 87398900 11 44.4 52.3 57.1 72.6 136.
## 3 87398950 39.8 58.4 76 82.3 98.3 160
## 4 87398980 9.4 42.4 49.7 51.5 62 114.
## 5 87405500 17 77.5 107 142. 171. 679
## 6 87406900 23.1 85.6 124. 164. 199. 619
## 7 87409900 56.1 114. 177 200. 242 454
(sum_cond_elet_p3 <- plan_wide_19902020 %>%
select(CODIGO, Condutividade, ANO_COLETA) %>%
filter(ANO_COLETA>"2010" &
ANO_COLETA<="2020") %>%
group_by(CODIGO) %>%
summarize(
min =
min(Condutividade,
na.rm = TRUE),
q1 =
quantile(Condutividade, 0.25,
na.rm = TRUE),
median =
median(Condutividade,
na.rm = TRUE),
mean =
mean(Condutividade,
na.rm= TRUE),
q3 =
quantile(Condutividade, 0.75,
na.rm = TRUE),
max =
max(Condutividade,
na.rm = TRUE),
n =
length(Condutividade))
)## # A tibble: 7 x 8
## CODIGO min q1 median mean q3 max n
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 87398500 0.01 68.5 80.2 80.4 99.5 125. 34
## 2 87398900 39.7 53.4 58.3 61.1 65.5 103 36
## 3 87398950 40.9 64.7 70.1 76.1 82.5 195. 35
## 4 87398980 43.2 51.7 54.0 56.3 61.0 78.9 28
## 5 87405500 47 85.8 121. 146. 209. 286 33
## 6 87406900 62.7 95.9 142. 163. 216. 354. 35
## 7 87409900 65.7 121. 159. 179. 245. 498. 37
# plan_wide_19902020 %>%
# select(CODIGO, IQA) %>%
# group_by(CODIGO) %>%
# summarize(
# min =
# min(IQA,
# na.rm = TRUE),
# q1 =
# quantile(IQA, 0.25,
# na.rm = TRUE),
# median =
# median(IQA,
# na.rm = TRUE),
# mean =
# mean(IQA,
# na.rm= TRUE),
# q3 =
# quantile(IQA, 0.75,
# na.rm = TRUE),
# max =
# max(IQA,
# na.rm = TRUE))Time for this code chunk to run: 0.194656133651733
ggsave("cond_elet.png",
units = c("px"),
width = 4500,
height = 2993,
plot = cond_elet,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("cond_elet_p1.png",
plot = cond_elet_p1,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("cond_elet_p2.png",
plot = cond_elet_p2,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("cond_elet_p3.png",
plot = cond_elet_p3,
path = "./graficos",
dpi = 300,
type = "cairo")
ggsave("cond_elet_3periodos.png",
units = c("px"),
width = 4500,
height = 2993,
plot = grid.arrange(cond_elet_p1, cond_elet_p2, cond_elet_p3, ncol = 3),
path = "./graficos",
dpi = 300,
type = "cairo")Time
for this code chunk to run: 6.0635941028595